//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
import gridFooter from "./orderSecond/small_order_item.vue";
import gridHeader from './orderSecond/PlaceAnOrder'
import orderDetails from './orderSecond/orderDetails'
// import RecordManually from '../../views/order/V_RecordManually.vue'
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: gridHeader,//{ template: "<div>扩展组xx件</div>" },
    gridBody: orderDetails,
    gridFooter: gridFooter,
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    // modelHeader: RecordManually,
    modelBody: '',
    modelFooter: ''
  },
  buttons: {
    view: [
    ], box: [], detail: [
    ]
  },//扩展的按钮
  methods: {//事件扩展
    onInit () {
      this.$store.getters.data().viewPageTest = this;
      this.single = true;
      this.textInline = true;
      this.ck = false;
      this.columnIndex = true;
      this.maxBtnLength = 3;
      this.boxOptions.height = 530;
      this.boxOptions.width = 900;
      this.pagination.sortName = "createDate";  //设置排序字段
      this.pagination.order = "desc"; //排序方式desc或者asc
      //this.searchFormFields.is_pay = 3;
      this.const.PAGE = 'GetPageDataSecond'
      this.$store.getters.data().order = this;
      this.columns.push({
        title: '操作',
        fixed: 'right',
        width: 200,
        render: (h, { row, column, index }) => {
          return h(
            "div", { style: {} }, [
            h(
              "a", {
              props: {},
              style: {},
              on: {
                click: (e) => {
                  this.$refs.gridBody.open(row);
                }
              }
            },
              "订单详情"
            ),
          ])
        }
      })
    },
    destroyed () {
      this.const.PAGE = 'getPageData'
    },
    onInited () {
      //this.height = this.height-300;
      this.detailOptions.height = this.detailOptions.height - 200;
    },
    order () {

      //this.$refs.gridHeader.reset();
      // this.searchAfter(rows);
      this.$refs.gridHeader.open1();
    },
    modelOpenAfter () {
      //获取当前弹出框是新建还是编辑状态
      let isEDIT = this.currentAction == this.const.EDIT;
      //  console.log(isEDIT);
      //点击弹出框后，如果是编辑状态，禁止编辑帐号，如果新建状态，将帐号字段设置为可编辑
      this.editFormOptions.forEach(item => {
        item.forEach(x => {
          //如果是编辑帐号设置为只读
          if (x.field == "order_number") {
            //disabled是editFormOptions的动态属性，这里只能通过this.$set修改值
            this.$set(x, "disabled", true)
          }
          if (x.field == "ticketsCode") {
            //disabled是editFormOptions的动态属性，这里只能通过this.$set修改值
            this.$set(x, "disabled", true)
          }
          if (x.field == "bookingName") {
            //disabled是editFormOptions的动态属性，这里只能通过this.$set修改值
            this.$set(x, "disabled", true)
          }
          if (x.field == "type") {
            //disabled是editFormOptions的动态属性，这里只能通过this.$set修改值
            this.$set(x, "disabled", true)
          }
          if (x.field == "status") {
            //disabled是editFormOptions的动态属性，这里只能通过this.$set修改值
            this.$set(x, "disabled", true)
          }
          if (x.field == "bookingPhone") {
            //disabled是editFormOptions的动态属性，这里只能通过this.$set修改值
            this.$set(x, "disabled", true)
          }
        })
      })
    },
    rowClick ({ row, column, event }) { //查询界面table点击行选中当前行
      //console.log(row,column,event);
      let where = {
        sort: "id",
        value: row.id
        //{"name":"refundStatus","value":2,displayType:"text"},
        //设置为like模糊查询
      };
      this.$refs.table.$refs.table.toggleRowSelection(row);
      this.$refs.gridFooter.$refs.tableList.load(where)
      if (this.$refs.table.getSelected().length > 1) {
        this.$refs.gridFooter.$refs.tableList.reset()
      }
      return true;
    },
    searchAfter (rows) {
      //页面加载或者刷新数据后直接显示第一行的明细
      //console.log(rows);
      if (rows.length) {
        let where = {
          sort: "id",
          value: rows[0].id
        };
        // this.$nextTick(() => {
        this.$refs.gridFooter.$refs.tableList.load(where)
        // })
      } else {
        //没有数据时，清空明细数据
        this.$refs.gridFooter.$refs.tableList.reset()
      }
      return true;
    },
    // loadInternalDetailTableBefore(param){
    //   console.log("查询数据前",param)
    //   param.wheres.push({"name":"order_id","value":param..va,displayType:"text"})
    //   console.log("查询数据前",param)
    // }
  }

};
export default extension;
